#ifndef AUDIOMANAGER_H
#define AUDIOMANAGER_H

//#include <SDL_mixer.h>
#include "game.h"
#include <vector>
#include <string>

/*
#include "sound.h"
#include "channel.h"
*/

using namespace std;

class AudioLoader
{
  /*
	public:
		~AudioManager();

		static AudioManager& self();
		static bool exists();

		//n_chan is how many sounds can be played at the same time
		bool init(int n_chan=8,int freq=
				MIX_DEFAULT_FREQUENCY,Uint16 format=MIX_DEFAULT_FORMAT,
				int stereo=MIX_DEFAULT_CHANNELS,int chunk=4096);
		void update();
		void shutdown();

		typedef struct
		{
			string name;
			int num_users;
			Mix_Chunk *chunk;
		}Chunk;

		////////////
		//SOUND
		////////////

		//Enable or disable the sound
		void enableSound(int ch = 8){loadChannels(ch);loadAllChunks();enable_sound=true;}
		void disableSound(){unloadChannels();unloadAllChunks();enable_sound=false;}
        bool getSoundEnabled(){ return enable_sound; }
        void setSoundEnabled(bool enabled);

		//Add or del a sound to the lists
		Sound* loadSound(string soundname);
		void unloadSound(Sound *s);

		//Play a sound if there is a free channel
		void playSound(Sound *s);

		//Change the num of channels
		void setChannels(int ch){unloadChannels();loadChannels(ch);}
		
		//Volume
		void setVolumeSound(int v){volume=v;}
		int getVolumeSound()const{return volume;}

		///////////
		//MUSIC
		///////////

		//Enable or disable the music
		void enableMusic(){enable_music=true; startMusic(); }
		void disableMusic(){stopMusic();enable_music=false;}
        bool getMusicEnabled(){ return enable_music;}
        void setMusicEnabled(bool enabled);

		//Load a song
		int loadMusic(string musicname);
		void unloadMusic();
        string getMusicName();

		//Manage the music
		void startMusic(int ms=0);
        void startMusic(bool once);
		void pauseMusic(){if(enable_music)Mix_PauseMusic();}
		void resumeMusic(){if(enable_music)Mix_ResumeMusic();}
		void stopMusic(int ms=0);
		void rewindMusic(){if(enable_music)Mix_RewindMusic();}

		//Volume
		int getVolumeMusic(){return enable_music?Mix_VolumeMusic(-1):0;}
		void setVolumeMusic(int v){if(enable_music)Mix_VolumeMusic(v);}
		void setPositionMusic(double pos){if(enable_music)
				Mix_SetMusicPosition(pos);}
		
	protected:
		AudioManager();

		static AudioManager* m_self;

		void loadChannels(int n_chan);
		void unloadChannels();

		void loadAllChunks();
		void unloadAllChunks();

	private:
		vector<Chunk*> chunks;
		Channel **channels;

		Mix_Music *music;
        string m_musicName;

		int num_channels;
		bool enable_music;
		bool enable_sound;
		int volume;
    bool m_initialized;
    */
};

#endif
